import { action, makeAutoObservable, observable } from 'mobx'

class HomeStore {
  // 配置可观察对象属性start
  @observable
  language: 'zh_CN' | 'en_US'

  @observable
  addUserDrawerVisible: boolean
  @observable
  selectTableVisible: boolean
  @observable
  formPlusExpand: boolean

  // 配置可观察对象属性end

  // 加入观察序列
  constructor(
    language: 'zh_CN' | 'en_US' = 'zh_CN',
    addUserDrawerVisible: boolean = false,
    selectTableVisible: boolean = false,
    formPlusEpand: boolean = false
  ) {
    this.language = language
    this.addUserDrawerVisible = addUserDrawerVisible
    this.selectTableVisible = selectTableVisible
    this.formPlusExpand = formPlusEpand
    makeAutoObservable(this)
  }

  // 配置可观察对象属性操作方法start
  @action
  changeLanguage = () => {
    console.log(this.language)
    if (this.language === 'zh_CN') {
      this.language = 'en_US'
    } else {
      this.language = 'zh_CN'
    }
  }

  @action
  changeAddUserDrawerVisible = () => {
    console.log(this.addUserDrawerVisible)
    this.addUserDrawerVisible = !this.addUserDrawerVisible
  }

  @action
  changeSelectTableVisible = () => {
    console.log(this.selectTableVisible)
    this.selectTableVisible = !this.selectTableVisible
  }

  @action
  changeFormPlusExpand = () => {
    this.formPlusExpand = !this.formPlusExpand
  }
  // 配置可观察对象属性操作方法start
}

// const Store = new HomeStore()

export default HomeStore
